package dipl.algorithm.math.fp.primitive.op;

/**
 * operations in complex number space
 */
public class ComplexOps {

	//
	// PUBLIC METHODS
	//

	/**
	 * calculates argument (in radians) of given complex number.
	 * The resulting angle lies in [0,2*PI]
	 * @param fpMath
	 * @param r
	 * @param i
	 * @return
	 */
	public static double Argument( double r, double i ) {
		double angle = 0.0;
		try {
			angle = Math.atan2( i, r );
		}
		catch( Exception e ) {
			return 0.0;
		}
		if( angle < 0.0 )
			return angle+2.0*Math.PI;
		return angle;
	}
}
